package com.unitechs.trap.write.webapi.service.impl;

import com.unitechs.trap.common.pojo.trap.entity.TrapVarName;
import com.unitechs.trap.excel.service.ITrapVarNameExcelService;
import com.unitechs.trap.write.service.ITrapVarNameService;
import com.unitechs.trap.write.webapi.mapper.TrapVarNameMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@DubboService
@Slf4j
@Service

public class TrapVarNameServiceImpl implements ITrapVarNameService {

    @Autowired
    private TrapVarNameMapper trapVarNameMapper;
    @DubboReference(timeout = 1*1024*1024*1024)
    private ITrapVarNameExcelService trapVarNameExcelService;

    @Override
    public int insertTrapVarNames() {
        List<TrapVarName> trapVarNames=trapVarNameExcelService.listTrapVarName();
        log.info("trapVarNames{}",trapVarNames);
        if (trapVarNames==null||trapVarNames.isEmpty()){
            return 0;
        }
        int i = trapVarNameMapper.insertTrapVarNames(trapVarNames);
        return i;
    }
}
